﻿<%@ Page Title="" Language="C#" MasterPageFile="~/Admin/AdminPage.master" Inherits="WebManager.BasePage" %>

<%@ Import Namespace="TalentPools.BLL" %>
<%@ Import Namespace="TalentPools.Model" %>
<%@ Register Assembly="AspNetPager" Namespace="Wuqi.Webdiyer" TagPrefix="webdiyer" %>
<script runat="server">

    string session;
    protected void Page_Load(object sender, EventArgs e)
    {
        AdminClass a = new AdminClass();
        if (!AdminLogin())//判断管理员是否登录
        {
            JsWindows("cookie已过期，请重新登录", "Admin_Login.aspx");
            return;
        }
        session = Request.Cookies["AdminUser"].Values["name"];
        if (!a.Exists_Purview(session, "2001"))
        {
            JsWindows("对不起，你没有权限进行此操作！", "Admin_Default.aspx");
            return;
        }
        if (!IsPostBack)
        {
            ViewState["PageIndex"] = 1;//默认第一页
            ViewState["where"] = "";//默认全部
            string qstr = QueryString("Action");
            switch (qstr)
            {
                case "Edit":
                    if (!a.Exists_Purview(session, "2001"))
                    {
                        JsWindows("对不起，你没有该操作的权限，如果需要更多的权限，请联系管理员", "");
                        return;
                    }
                    EditVoid();
                    break;
                case "Del":
                    if (!a.Exists_Purview(session, "2001"))
                    {
                        JsWindows("对不起，你没有该操作的权限，如果需要更多的权限，请联系管理员", "");
                        return;
                    }
                    DelVoid();
                    break;
                case "Set":
                    if (!a.Exists_Purview(session, "2001"))
                    {
                        JsWindows("对不起，你没有该操作的权限，如果需要更多的权限，请联系管理员", "");
                        return;
                    }
                    SetVoid();
                    break;

            }
            AspNetPager1.RecordCount = new checkresumeManager().GetResumeCount(ViewState["where"].ToString());
            DataBind1();
        }
    }
    public void SetVoid()
    {
        bool result = false;
        int id = Convert.ToInt32(QueryString("id"));
        string state = QueryString("state");
        if (state == "True")
        {
            result = false;
        }
        else
        {
            result = true;
        }
        new alertResumeManager().UpdateResumeState(id, result);
    }
    public void EditVoid()
    {
        bool result = false;
        int id = Convert.ToInt32(QueryString("id"));
        string state = QueryString("state");
        if (state == "True")
        {
            result = false;
        }
        else
        {
            result = true;
        }
        new alertResumeManager().UpdateRstate(id, result);
    }
    public void DelVoid()
    {

        JsWindows("抱歉，此功能尚未开放", "");
        return;
    }
    public void DataBind1()
    {
        RP1.DataSource = new checkresumeManager().GetResumePage(Convert.ToInt32(ViewState["PageIndex"]), 10, ViewState["where"].ToString());
        RP1.DataBind();
    }
    #region 检查求职意向
    /// <summary>
    /// 检查求职意向
    /// </summary>
    /// <returns></returns>
    public string showIntention()
    {
        string showIntention = "";
        int resumeId = Convert.ToInt32(Eval("Id"));
        List<intention> list = new IntentionManager().GetIntentionByResumeId(resumeId);
        if (list.Count>=1)
        {
            showIntention = "<a href='../ResumeShow.aspx?resumeId=" + list[0].resumeId + "' target='_blank'>工作性质：" + list[0].jobCategory + "," + "意向职位：" + list[0].profession + "</a>";
        }
        else
        {
            showIntention = "<span style='color:red'>※该会员未填写任何求职意向※</span>";
        }
        return showIntention;
    }
    #endregion

    #region 检查工作经历
    /// <summary>
    /// 检查工作经历
    /// </summary>
    /// <returns></returns>
    public string showRecord()
    {
        string showRecord = "";
        int resumeId = Convert.ToInt32(Eval("Id"));
        List<record> list = new RecordManager().GetRecord(resumeId);
        if (list.Count >= 1)
        {
            showRecord = "<a href='../ResumeShow.aspx?resumeId=" + list[0].resumeId + "' target='_blank'>工作标题：" + list[0].title + "," + "工作内容：" + list[0].content + "</a>";
        }
        else
        {
            showRecord = "<span style='color:red'>※该会员未填写工作履历※</span>";
        }
        return showRecord;
    }
    #endregion

    #region 检查专业技能
    /// <summary>
    /// 检查专业技能
    /// </summary>
    /// <returns></returns>
    public string showSkill()
    {
        string showSkill = "";
        int resumeId = Convert.ToInt32(Eval("Id"));
        List<Skill> list = new SkillManager().GetSkill(resumeId);
        if (list.Count >= 1)
        {
            showSkill = "<a href='../ResumeShow.aspx?resumeId=" + list[0].resumeId + "' target='_blank'>：" + list[0].Name + "</a>";
        }
        else
        {
            showSkill = "<span style='color:red'>※该会员未填写专业技能※</span>";
        }
        return showSkill;
    }
    #endregion

    #region 检查附加信息
    /// <summary>
    /// 检查附加信息
    /// </summary>
    /// <returns></returns>
    public string showCustom()
    {
        string showCustom = "";
        int resumeId = Convert.ToInt32(Eval("Id"));
        List<custom> list = new CustomManager().GetCustom(resumeId);
        if (list.Count >= 1)
        {
            showCustom = "<a href='../ResumeShow.aspx?resumeId=" + list[0].resumeId + "' target='_blank'>：" + list[0].tittle + "</a>";
        }
        else
        {
            showCustom = "<span style='color:red'>※该会员未填写自定义信息※</span>";
        }
        return showCustom;
    }
    #endregion
    public string pbshow()
    {
        string str = Eval("isPb").ToString();
        if (str == "True")
        {
            return "<span style='color:red;'>屏蔽</span>";
        }
        else
        {
            return "普通";
        }
    }
    public string tjshow()
    {
        string str = Eval("isTj").ToString();
        if (str == "True")
        {
            return "<span style='color:red;'>！推荐</span>";
        }
        else
        {
            return "普通";
        }
    }
    protected void btnSearch_Click(object sender, EventArgs e)
    {
        ViewState["where"] = searchText.Text.Trim();
        AspNetPager1.RecordCount = new checkresumeManager().GetResumeCount(ViewState["where"].ToString());
        DataBind1();
    }

    protected void AspNetPager1_PageChanging(object src, PageChangingEventArgs e)
    {
        ViewState["PageIndex"] = e.NewPageIndex;
    }

    protected void dlResume_DeleteCommand(object source, DataListCommandEventArgs e)
    {
        if (new checkresumeManager().deletResumeByid(Convert.ToInt32(e.Item.ItemIndex)))
            DataBind1();
    }

    protected void btnDelete_Click(object sender, EventArgs e)
    {
        string select_Val = Request["ic"];
        if (select_Val == null)
        {
            return;
        }
        string[] id = select_Val.Split(',');
        foreach (string item in id)
        {
            new checkresumeManager().deletResumeByid(Convert.ToInt32(item));
        }
    }

    protected void btnPb_Click(object sender, EventArgs e)
    {
        string select_Val = Request["ic"];
        if (select_Val == null)
        {
            return;
        }
        string[] id = select_Val.Split(',');
        foreach (string item in id)
        {
            new alertResumeManager().UpdateResumeState(Convert.ToInt32(item), false);
        }
    }

    protected void btnNom_Click(object sender, EventArgs e)
    {
        string select_Val = Request["ic"];
        if (select_Val == null)
        {
            return;
        }
        string[] id = select_Val.Split(',');
        foreach (string item in id)
        {
            new alertResumeManager().UpdateRstate(Convert.ToInt32(item), false);
        }
    }

    protected void btnTJ_Click(object sender, EventArgs e)
    {
        string select_Val = Request["ic"];
        if (select_Val == null)
        {
            return;
        }
        string[] id = select_Val.Split(',');
        foreach (string item in id)
        {
            new alertResumeManager().UpdateResumeState(Convert.ToInt32(item), true);
        }
    }

    protected void qxtj_button_Click(object sender, EventArgs e)
    {
        string select_Val = Request["ic"];
        if (select_Val == null)
        {
            return;
        }
        string[] id = select_Val.Split(',');
        foreach (string item in id)
        {
            new alertResumeManager().UpdateResumeState(Convert.ToInt32(item), false);
        }
    }
</script>
<asp:Content ID="Content1" ContentPlaceHolderID="head" runat="Server">
    <script type="text/javascript">
        function checkAll() {
            var oInput = document.getElementsByName("ic");
            for (var i = 0; i < oInput.length; i++) {
                if (document.getElementById("all").checked == true) {
                    oInput[i].checked = true;
                }
                else {
                    oInput[i].checked = false;
                }
            }
        }

        function checkSingle() {
            var oInput = document.getElementsByName("ic");
            var j = 0;
            for (var i = 0; i < oInput.length; i++) {
                if (oInput[i].checked == true) {
                    j = j + 1;
                }
            }

            if (j == oInput.length) {
                document.getElementById("all").checked = true;
            }
            else {
                document.getElementById("all").checked = false;
            }
        }
    </script>
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="ContentPlaceHolder1" runat="Server">
    <asp:Panel ID="ManageP" runat="server">
        <table width='100%' border='0' align='center' cellpadding='2' cellspacing='1' class='border'>
            <tr class='topbg2'>
                <td width="100%" align='center'>
                    <strong class="Glow">求 职 用 户 管 理</strong>
                </td>
            </tr>
        </table>
        <table border="0" width="100%">
            <tr>
                <td>
                    搜索登陆名：
                    <asp:TextBox ID="searchText" runat="server"></asp:TextBox>
                    <asp:Button ID="btn_search" runat="server" Text="搜 索" OnClick="btnSearch_Click" />
                </td>
            </tr>
        </table>
        <table width='100%' border='0' align='center' cellpadding='4' cellspacing='1' class='border'>
            <tr class='topbg2'>
                <td width="6%" align='center'>
                    <strong class="Glow">选中</strong>
                </td>
                <td width="10%" align='center'>
                    <strong class="Glow">登录名</strong>
                </td>
                <td width="14%" align='center'>
                    <strong class="Glow">简历名称</strong>
                </td>
                <td width="11%" align='center'>
                    <strong class="Glow">求职意向</strong>
                </td>
                <td width="10%" align='center'>
                    <strong class="Glow">工作履历</strong>
                </td>
                <td width="14%" align='center'>
                    <strong class="Glow">精通技能</strong>
                </td>
                <td width="10%" align='center'>
                    <strong class="Glow">附加信息</strong>
                </td>
                <td width="15%" align='center'>
                    <strong class="Glow">推荐/屏蔽/操作</strong>
                </td>
            </tr>
            <asp:Repeater ID="RP1" runat="server">
                <ItemTemplate>
                    <tr class='tdbg' onmouseout="this.className='tdbg'" onmouseover="this.className='tdbgmouseover'">
                        <td width="6%" align='center'>
                            <input name="ic" type="checkbox" size="12px" onclick="checkSingle()" style="width: 20px"
                                value='<%#Eval("Id") %>' />
                        </td>
                        <td width="10%" align='center'>
                            <%#Eval("username") %>
                        </td>
                        <td width="14%" align='center'>
                            <%#Eval("resumeName") %>
                        </td>
                        <td width="11%" align='center'>
                            <%#showIntention() %>
                        </td>
                        <td width="10%" align='center'>
                            <%#showRecord() %>
                        </td>
                        <td width="14%" align='center'>
                            <%#showSkill() %>
                        </td>
                        <td width="10%" align='center'>
                            <%#showCustom() %>
                        </td>
                        <td align="center">
                            <a href="?Action=Set&id=<%#Eval("Id") %>&state=<%#Eval("isTj") %>">
                                <%#tjshow() %></a> | <a href="?Action=Edit&id=<%#Eval("Id")%>&state=<%#Eval("isPb") %>">
                                    <%#pbshow() %></a> | <a href="?id=<%#Eval("Id") %>&Action=Del" onclick="return confirm('警告！删除此会员将会删除其所有其他相关资料！此操作不可逆。');">
                                        删除</a>
                        </td>
                    </tr>
                </ItemTemplate>
            </asp:Repeater>
        </table>
        <div>
            <input name='all' type='checkbox' onclick='checkAll()' value='checkbox' />
            <asp:Button ID="del_button" runat="server" Text="删 除" OnClick="btnDelete_Click" />
            <asp:Button ID="dj_button" runat="server" Text="屏 蔽" OnClick="btnPb_Click" />
            <asp:Button ID="zc_button" runat="server" Text="取消屏蔽" OnClick="btnNom_Click" />
            <asp:Button ID="tj_button" runat="server" Text="推 荐" OnClick="btnTJ_Click" />
            <asp:Button ID="qxtj_button" runat="server" Text="取消推荐" OnClick="qxtj_button_Click" />
            <div style="float: right; width: 60%; height: 28px; text-align: right">
                <webdiyer:AspNetPager ID="AspNetPager1" runat="server" OnPageChanging="AspNetPager1_PageChanging">
                </webdiyer:AspNetPager>
            </div>
        </div>
        <div id="paging" runat="server">
        </div>
    </asp:Panel>
</asp:Content>
